<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>

<body>
    <div id="app">
        <h3>鼠标移入移出透明度改变</h3>
        <img src="img/1.png"  @mouseout="out1" @mouseover="over1" alt="">
        <hr>
        <h3>鼠标移入移出切换图片</h3>
        <img :src="imgSrc" @mouseout="out2" @mouseover="over2" alt="">
        <br>
    </div>
    <script>
         var app = new Vue({
            el:'#app',
            data() {
                return {
                    imgSrc:'img/1.png'
                }
            },
            methods:{
                over1(e){
                    e.target.style.opacity = 0.5;
                },
                out1(e){
                    e.target.style.opacity = 1;
                },
                out2(e){
                    this.imgSrc = 'img/1.png'
                },
                over2(e){
                    this.imgSrc = 'img/2.png'
                }
            }
        })
    </script>
</body>

</html>